package com.markus.code.exam.xiaomi;

import com.markus.basic.Java基础.重写与重载.A;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/8 18:22
 * todo:
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String str = scanner.nextLine();
            String[] passwords = str.split(" ");
            Main demo = new Main();
            List<Integer> process = demo.process(passwords);
            for (Integer integer : process) {
                System.out.println(integer);
            }
        }
    }
    private List<Integer> process(String[] passwords){
        //1、先判断长度
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<passwords.length;i++){
            if (!judgeLength(passwords[i])){
                list.add(1);
            }else if (!typePassword(passwords[i])){
                list.add(2);
            }else{
                list.add(0);
            }
        }
        return list;
    }
    private boolean judgeLength(String password){
        if (password.length() >= 8 && password.length() <= 120){
            return true;
        }else{
            return false;
        }
    }
    private boolean typePassword(String password){
        char[] chars = password.toCharArray();
        boolean upFlag = false;
        boolean lowFlag = false;
        boolean otherFlag = false;
        boolean numFlag = false;
        for (int i = 0; i < chars.length;i++){
            if (chars[i] >= 'a' && chars[i] <= 'z'){
                lowFlag = true;
            }else if (chars[i] >= 'A' && chars[i] <= 'Z'){
                upFlag = true;
            }else if (chars[i] >= '0' && chars[i] <= '9'){
                numFlag = true;
            }else{
                otherFlag = true;
            }
        }
        return lowFlag && upFlag && otherFlag && numFlag;
    }
}
